import pymysql
try:
    conn=pymysql.connect(
        host='localhost',
        port=3306,
        db='mydb',
        user='root',
        passwd='root',
        charset='utf8')
    cur=conn.cursor()
    shopName = input("请输入你要修改的商品名称：\n")
    #sql = "select * from ecs_goods where goods_name='%s'"%shopName
    sql = "select * from ecs_goods where goods_name=%s"
    param = (shopName,)
    cur.execute(sql,param)
    result = cur.fetchall()
    if result:
        column = input("请输入要修改的类型:\n")
        newName = input("请输入新值：\n")
        sql = "update ecs_goods set goods_name=%s where %s =%s"
        param = (newName,column,shopName)
        cur.execute(sql)
    conn.commit()
    cur.close()
    conn.close()
except Exception:
    print("数据库连接错误")